﻿/*!	@file	r_raytrace_camera.h
	@brief	raytraceカメラ定義
Copyright (c) 2011 Yuya Yamaguchi

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifndef _R_RAYTRACE_CAMERA_H_
#define _R_RAYTRACE_CAMERA_H_

#include "../math/r_math_vector3.h"
#include "../math/r_math_matrix34.h"
#include "../alloc/r_alloc_new_delete.h"
#include "r_raytrace_allocator.h"

namespace r{
	namespace raytrace{
		//! カメラ
		class Camera{
		public:
			RALLOC_PLACEMENT_NEW_DELETE ( r::raytrace::AllocatorData()() )
		public:
			//! コンストラクタ
			/*!
			*/
			Camera( void )
			: forcalLength(1.0f)
			, aspectRatio(1280.0f / 720.0f){
				locale.identity();
			}
			//! デストラクタ
			/*!
			*/
			~Camera( void ){
			}
			//! 姿勢を取得
			inline	const r::math::Matrix34&	getLocale( void )const{
				return locale;
			}
			//! 視線レイを取得する
			/*!
			@param	x	-1.0f～1.0f X方向サンプリング位置
			@param	y	-1.0f～1.0f Y方向サンプリング位置
			*/
			inline	const r::math::Vector3D		getEyeVector( r_f32 x, r_f32 y )const{
				return r::math::Vector3D(0,0,1);
			}
			//! スクリーンまでの距離を取得する
			/*!
			*/
			inline	r_f32	getForcalLength( void )const{
				return forcalLength;
			}
			//! アスペクト比を取得する
			/*!
			*/
			inline	r_f32	getAspectRatio( void )const{
				return aspectRatio;
			}
		public:
			//! 姿勢を設定する
			/*!
			*/
			inline	void	setLocale( const r::math::Matrix34& mat ){
				locale = mat;
			}
			//! スクリーンまでの距離を設定する
			/*!
			*/
			inline	void	setForcalLength( r_f32 len ){
				forcalLength = len;
			}
			//! アスペクト比を取得する
			/*!
			*/
			inline	r_f32	setAspactRatio( r_f32 ratio ){
				aspectRatio = ratio;
			}
		protected:
		private:
			//! ワールドカメラ座標
			r::math::Matrix34	locale;
			//! スクリーンまでの距離
			r_f32				forcalLength;
			//! 縦横比
			r_f32				aspectRatio;
		};
	}
}

#endif // _R_RAYTRACE_CAMERA_H_

